package com.ruoyi.web.controller.ydz;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.ExaminationNews;
import com.ruoyi.web.service.IExaminationNewsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 体检新闻Controller
 * 
 * @author drx
 * @date 2025-05-19
 */
@Controller
@RequestMapping("/ydz/examinationNews")
@Api(tags = "体检新闻")
public class ExaminationNewsController extends BaseController
{
    private String prefix = "ydz/examinationNews";

    @Autowired
    private IExaminationNewsService examinationNewsService;

    @RequiresPermissions("ydz:examinationNews:view")
    @GetMapping()
    public String news()
    {
        return prefix + "/examinationNews";
    }

    /**
     * 查询体检新闻列表
     */
    @RequiresPermissions("ydz:examinationNews:list")
    @PostMapping("/list")
    @ResponseBody
    @ApiOperation("查询体检新闻列表")
    public TableDataInfo list(ExaminationNews examinationNews)
    {
        startPage();
        List<ExaminationNews> list = examinationNewsService.selectExaminationNewsList(examinationNews);
        return getDataTable(list);
    }

    /**
     * 导出体检新闻列表
     */
    @RequiresPermissions("ydz:examinationNews:export")
    @Log(title = "体检新闻", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    @ApiOperation("导出体检新闻列表")
    public AjaxResult export(ExaminationNews examinationNews)
    {
        List<ExaminationNews> list = examinationNewsService.selectExaminationNewsList(examinationNews);
        ExcelUtil<ExaminationNews> util = new ExcelUtil<ExaminationNews>(ExaminationNews.class);
        return util.exportExcel(list, "体检新闻数据");
    }

    /**
     * 新增体检新闻
     */
    @GetMapping("/add")
    @ApiOperation("新增体检新闻")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存体检新闻
     */
    @ApiOperation("新增保存体检新闻")
    @RequiresPermissions("ydz:examinationNews:add")
    @Log(title = "体检新闻", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ExaminationNews examinationNews)
    {
        return toAjax(examinationNewsService.insertExaminationNews(examinationNews));
    }

    /**
     * 修改体检新闻
     */
    @ApiOperation("修改体检新闻")
    @RequiresPermissions("ydz:examinationNews:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ExaminationNews examinationNews = examinationNewsService.selectExaminationNewsById(id);
        mmap.put("examinationNews", examinationNews);
        return prefix + "/edit";
    }

    /**
     * 修改保存体检新闻
     */
    @ApiOperation("修改保存体检新闻")
    @RequiresPermissions("ydz:examinationNews:edit")
    @Log(title = "体检新闻", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ExaminationNews examinationNews)
    {
        return toAjax(examinationNewsService.updateExaminationNews(examinationNews));
    }

    /**
     * 删除体检新闻
     */
    @ApiOperation("删除体检新闻")
    @RequiresPermissions("ydz:examinationNews:remove")
    @Log(title = "体检新闻", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(examinationNewsService.deleteExaminationNewsByIds(ids));
    }

    @ResponseBody
    @PostMapping("/editState")
    public AjaxResult editState(@RequestBody ExaminationNews examinationNews){
        return toAjax(examinationNewsService.updateExaminationNews(examinationNews));
    }

    /**
     * 日本体检TDK配置
     */
    @ApiOperation("日本体检TDK配置")
    @RequiresPermissions("ydz:examinationNews:tdkSet")
    @GetMapping("/tdkEdit")
    public String tdkEdit()
    {
        return prefix + "/ExaminationSet";
    }
}
